package study;
/**
 * 懒汉单例模式
 */
public class singletom {
    //在单例子类的内部创建一个自己本身的对象
    private static singletom instance = new singletom();

    //构造器的私有化
    private singletom() {

    }

    public static singletom getInstance() {
        return instance;
    }


}

/**
 * 测试代码
 */
class TestSingle {
    public static void main(String[] args) {
        singletom s = singletom.getInstance();
        singletom s1 = singletom.getInstance();
//        singletom s2 = singletom.getInstance();
//        singletom s3 = singletom.getInstance();
        System.out.println(s);
        System.out.println(s1);
//        System.out.println(s2);
//        System.out.println(s3);
    }
}